﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using GraphSharp.Controls;

namespace Flux_Balance_Analysis
{
    public partial class Styles : ResourceDictionary
    {
        private void EdgeControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Reaction r = (sender as EdgeControl).Edge as Reaction;
            ReactionWindow w = new ReactionWindow(r);
            bool? res = w.ShowDialog();
            if (res.HasValue && res.Value)
            {
                if (r != w.Reaction)
                {
                    FBACore.RemoveReaction(r);
                    if (w.Reaction != null)
                    {
                        FBACore.AddReaction(w.Reaction);
                    }
                }
            }
            e.Handled = true;
        }
        private void VertexControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Metabolite m = (sender as VertexControl).Vertex as Metabolite;
            MetaboliteWindow w = new MetaboliteWindow(m);
            bool? res = w.ShowDialog();
            if (res.HasValue && res.Value)
            {
                if (m != w.Metabolite)
                {
                    FBACore.RemoveMetabolite(m);
                    if (w.Metabolite != null)
                        FBACore.AddMetabolite(w.Metabolite);
                }
            }
            e.Handled = true;
        }
    }
}
